package title;

import java.util.Scanner;

/**
 * 功能：
 * 作者：lc
 * 日期：2025/1/30 0:38
 */
public class MainP1909 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int money = -1;
        int res = 1000000000;
        int claNum = scanner.nextInt();
        for (int i = 0; i < 3; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int mod = claNum % a;
            int num = claNum / a;
            num = mod == 0 ? num : num + 1;
            money = num * b;
            if (res > money) {
                res = money;
            }

        }
        System.out.println(res);

    }
}
